<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        //封装继承(原型的继承)
        //构造器是该对象原型的构造器，是指向子类的
        function extend(z_obj,f_obj){
              z_obj.prototype=Object.create(f_obj.prototype);
              //再让原型的constructor无法被for遍历
              Object.defineProperty(z_obj.prototype,"constructor",{
                  value: z_obj,
                  Enumerator:false
              });
        }

        //父类
       function user(name,age){
           this.name=name;
           this.age=age;
       }
       user.prototype.show=function(){
           console.log(this.name,this.age);
       };
      
       //子类
       function admin(...args){
           user.apply(this,args);
       }

       //使用继承方法
       extend(admin,user);
        
       let admins=new admin("唐玮",22);
       admins.show();//唐玮 22
       
    </script>
</body>
</html>